<template>
  <div class='app-container'>
    <div class='breadcrumb'>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">考务中心</el-breadcrumb-item>
        <el-breadcrumb-item>考试列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        fixed
        prop="id"
        label="序号"
        width="60">
      </el-table-column>
      <el-table-column
        prop="post_title"
        label="名称">
      </el-table-column>
      <el-table-column
        prop="enroll_time"
        width="300"
        label="报名时间">
      </el-table-column>

      <el-table-column
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">选择</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  import http from '@/utils/http'
  import api from '@/api_kaowu'
  export default {
    methods: {
      handleClick(row) {
        console.log(row);
        http.post(api.setUserCurrentExam,{examid:row.id})
            .then(() => {
              this.$router.push('/personal/kaowu/article')
            })
            .catch(err => {
                console.log(err)
            })

      },
      init(){
        http.post(api.examList)
            .then(res => {
              console.log(res)
              this.tableData = res.data

            })
            .catch(err => {
                console.log(err)
            })
      }
    },
    created () {
       this.init()
     },

    data() {
      return {
        tableData: []
      }
    }
  }
</script>

<style lang="scss" scoped>

  .app-container{background:#fff;padding:40px 20px;overflow:auto;}
  .breadcrumb{margin-bottom: 20px;}

</style>
